package com.lge.clock.stopwatch;

import java.util.List;

import com.lge.clock.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

/**
 * @author lge.com
 */
public class StopWatchAdapter extends ArrayAdapter<LapValue>
{
	private List<LapValue> mItems;
	private LayoutInflater mInflater;
	public StopWatchAdapter(Context context, int resource, List<LapValue> items) 
	{
		super(context, resource, items);
		mItems = items;
		mInflater = LayoutInflater.from(context);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) 
	{
		if(convertView == null)
		{
			convertView = mInflater.inflate(R.layout.stopwatch_row, null);
		}
		convertView.setClickable(true);
		LapValue lv = mItems.get(position);
		TextView lap_count = (TextView)convertView.findViewById(R.id.sw1_lap_textview);
		TextView lap_time1 = (TextView)convertView.findViewById(R.id.sw2_lap_textview);
		TextView lap_time2 = (TextView)convertView.findViewById(R.id.sw3_lap_textview);
		
		lap_count.setText(lv.getLap_count());
		lap_time1.setText(lv.getLap_time1());
		lap_time2.setText(lv.getLap_time2());
		return convertView;
	}	
}
